<template>
  <div class="">
    <div>
      进入主页...
    </div>
  </div>
</template>

<script>

import { loginByCode} from "@/api/selfcom/wework";
import {setToken} from "@/utils/auth";

export default {
  name: "weworklogin",
  components: {  },
  data() {
    return {
      isLogin: false,
    };
  },
  created() {
    let code = this.$route.query.code
    this.weworkLogin(code);
  },
  methods: {
    weworkLogin(code) {
      if(!this.isLogin) {
        let param = {
          "code": code
        }
        loginByCode(param).then(response => {
          console.log("weworkLogin response", JSON.stringify(response))

          setToken(response.token)
          commit('SET_TOKEN', response.token)
          this.isLogin = true;
          this.$router.push({ path: "http://p.yunwow.cn/cpages/terminal" || "/" });
          // window.location.href = "http://p.yunwow.cn/cpages/terminal";
        })
      } else {
      }
    },

  }
};
</script>
<style>

</style>
